#load "unix.cma";
#load "graphics.cma";;
#load "bplib.cma";;

#load "listMap.cmo";;
#load "bopprocesstools.cmo";;

#load "parserSSA.cmo";;
#load "lexerSSA.cmo";;

open Bopprocesstools

(* ==================================================================== *)
(** Parser le source *)
(* ===================================================================== *)
let parse_code_of_file filename =
  try
    index_ligne_net_list := 1;
    let ic = open_in filename in
    let buff = Lexing.from_channel ic in
    let youpi = ParserSSA.net_list LexerSSA.lexem_list buff
    in
    begin
      close_in ic;
      youpi
    end
  with
  | Sys_error _ -> 
      Printf.fprintf stderr "[!] '%s' : Not such file\n" filename;
      exit 1;
      failwith "w"
  | Parsing.Parse_error ->
      Printf.fprintf stderr "[!] line %d : Syntax Error\n" !index_ligne_net_list;
      exit 1;
      failwith "w"
  | Failure m ->
      Printf.fprintf stderr "[!] line %d : \"%s\"\n" !index_ligne_net_list m;
      exit 1;
      failwith "w"
(* ===================================================================== *)
;;

let pcode = parse_code_of_file "sp2.bpp";;
let (env, n), code = code_of_parse_code Prim.prims 4 pcode;;

env.(0).(0) <- true;;
exec_operation (env, n) code.(1);;
env;;

open Bplib;;

BoolArray.to_int env.(1);;
let t = Array.make 4 false;;
BoolArray.load_of_int t 14;;
t;;
